﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using App.Interface;
using App.Model;
using App.MVC.App_Start;
using Newtonsoft.Json;

namespace App.MVC.Controllers
{
    public class FuJiaXiangController : BaseController
    {
        public IFuJiaXiang _IFuJiaXiang { set; get; }
        public IPingShen _IPingShen { set; get; }
        // GET: FuJiaXiang
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Config()
        {
            return View();
        }

        public JsonResult GetFuJiaXiangs()
        {
            var str = _IFuJiaXiang.GetFuJiaXiangs();
            List<FuJiaXiang> tt = JsonConvert.DeserializeObject<List<FuJiaXiang>>(str);
            return Json(tt, JsonRequestBehavior.AllowGet);
        }

        public void AddFuJiaXiang(FuJiaXiang model)
        {
            string str = JsonConvert.SerializeObject(model);
            _IFuJiaXiang.AddFuJiaXiang(str);
        }

        public void DelFuJiaXiang(int fjxid)
        {
            _IFuJiaXiang.DelFuJiaXiang(fjxid);
        }

        public ActionResult AddMyKHBFJX()
        {
            return View();
        }

        public void MKHBAddFJX(int mkhbid, int fjxid, decimal fz)
        {
            _IFuJiaXiang.MyKaoHeBiaoAddFuJiaXiang(mkhbid,fjxid,fz,SiteInfo.GetUserName());
        }

        public void MHKBDelFJX(int fjxid, int mkhbid)
        {
            _IFuJiaXiang.MyKaoHeBiaoDelFuJiaXiang(mkhbid,fjxid);
        }
        /// <summary>
        /// 考核表附加项集
        /// </summary>
        /// <param name="mkhbid"></param>
        /// <returns></returns>
        public JsonResult GetMyKaoHeBiaoFuJiaXiang(int mkhbid)
        {
          var str=  _IFuJiaXiang.GetMyKHBFJXs(mkhbid);
          List<MyKaoHeBiaoFuJiaBiao> tt = JsonConvert.DeserializeObject<List<MyKaoHeBiaoFuJiaBiao>>(str);
          return Json(tt, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 根据时间获取考核表
        /// </summary>
        /// <param name="sssj"></param>
        /// <returns></returns>
        public JsonResult GetMyKaoHeBiaoBydatetime(string sssj)
        {
            var str = _IPingShen.GetMyKaoHeBiaosBydatetime(SiteInfo.GetUserName(),sssj);
            List<MyKaoHeBiao> tt = JsonConvert.DeserializeObject<List<MyKaoHeBiao>>(str);
            return Json(tt, JsonRequestBehavior.AllowGet);
        }
    }
}